﻿using System;
using GeoAPI.Geometries;

namespace NetTopologySuite.Algorithm
{
	[Obsolete("Use Centroid instead")]
	public class CentroidPoint
	{
		public void Add(IGeometry geom)
		{
			if (geom is IPoint)
			{
				this.Add(geom.Coordinate);
				return;
			}
			if (geom is IGeometryCollection)
			{
				foreach (IGeometry geom2 in ((IGeometryCollection)geom).Geometries)
				{
					this.Add(geom2);
				}
			}
		}

		public void Add(Coordinate pt)
		{
			this._ptCount++;
			this._centSum.X += pt.X;
			this._centSum.Y += pt.Y;
		}

		public Coordinate Centroid
		{
			get
			{
				return new Coordinate
				{
					X = this._centSum.X / (double)this._ptCount,
					Y = this._centSum.Y / (double)this._ptCount
				};
			}
		}

		private int _ptCount;

		private readonly Coordinate _centSum = new Coordinate();
	}
}
